ELEMENTS

Editing
  • account_tree
  • bug_report

<option>

<select> 요소의 선택 항목을 나타내거나 <datalist> 요소의 자료 항목을 나타낸다.

  • 콘텐츠 분류

    NONE

  • 허용된 부모 요소 또는 위치

    <DATALIST>, <OPTGROUP>, <SELECT>

  • 콘텐츠 모델

    NOTHING, TEXT

    • labelvalue 애트리뷰트가 있는 경우: Nothing
    • label 애트리뷰트가 있지만 value 애트리뷰트가 없는 경우: Text
    • label 애트리뷰트가 없고 <datalist> 요소의 하위 요소가 아닌 경우: Text
    • label 애트리뷰트가 없고 <datalist> 요소의 하위인 경우: Text
  • 태그 생략

    종료 태그 생략 가능

    <option> 요소 바로 뒤에 다른 <option> 요소 또는 <optgroup>, <hr> 요소가 오거나  이후에 더 이상 콘텐츠가 없는 경우 종료 태그를 생략할 수 있다.

  • DOM Interface

    HTMLOptionElement

    [Exposed=Window,
     LegacyFactoryFunction=Option(optional DOMString text = "", optional DOMString value, optional boolean defaultSelected = false, optional boolean selected = false)]
    interface HTMLOptionElement : HTMLElement {
      [HTMLConstructor] constructor();
    
      [CEReactions] attribute boolean disabled;
      readonly attribute HTMLFormElement? form;
      [CEReactions] attribute DOMString label;
      [CEReactions] attribute boolean defaultSelected;
      attribute boolean selected;
      [CEReactions] attribute DOMString value;
    
      [CEReactions] attribute DOMString text;
      readonly attribute long index;
    };
    

구문

마크업 형식
<select> <option></option>
</select>
마크업 형식
<datalist> <option></option>
</datalist>

애트리뷰트

disabled boolean attributes

요소를 비활성화한다.

About Boolean attributes

불리언(boolean) 값을 나타낸다. 예를 들어 다음 세 가지 값은 모두 참(true)이다.

<input disabled>, <input disabled="disabled">, <input disabled="">

label 

<option> 요소의 값에 대한 별칭이거나 <optgroup> 요소에서 표시되는 그룹 레이블을 나타낸다.

이 요소에서의 특징

하위에 텍스트가 있다면 label 애트리뷰트보다 우선하여 표시된다.

selected boolean attributes

기본적으로 선택된 항목임을 나타낸다.

About Boolean attributes

불리언(boolean) 값을 나타낸다. 예를 들어 다음 세 가지 값은 모두 참(true)이다.

<input disabled>, <input disabled="disabled">, <input disabled="">

value 

입력 요소의 기본 값을 지정한다.

글로벌 애트리뷰트

일부 글로벌 애트리뷰트는 이 요소에서 사용되지 않을 수 있다.

글로벌 이벤트 핸들러

일부 글로벌 이벤트 핸들러는 이 요소에서 사용되지 않을 수 있다. 이벤트 등록은 자바스크립트 사용을 권장한다.

버전 명세

HTML Standard
#the-option-element

지원 웹브라우저